const path = require('path');





// 返回一个解析后的绝对路径
//
// let pp1 = path.resolve('aa', 'bb', 'cc', 'dd')
// console.log('未加入绝对路径标识:', pp1)
// let pp2 = path.resolve('/bb', 'cc', '/dd')
// console.log('加入绝对路径标识:', pp2)
//
// return;


let p1 = 'aa', p2 = 'bb', p3 = 'cc';
let filename = 'test.txt';
// fullpath = path.join(p1, p2, p3, filename)
fullpath = path.join(...[p1, p2, p3, filename])
console.log('完整路径:', fullpath)  //  aa\bb\cc\test.txt

basename = path.basename(fullpath)
console.log('basename:', basename)  // test.txt

console.log('dirname:', path.dirname(fullpath))  // aa\bb\cc
console.log('extname:', path.extname(fullpath))  // .txt (注: 这里带".")

console.log('文件扩展名:', path.extname(fullpath))  //  .txt



//
// console.log('当前文件所在目录', __dirname)  // E:\lanlang\vue2-learning\nodejs
// console.log('当前文件所在路径', __filename)  // E:\lanlang\vue2-learning\nodejs\路径path.js




